<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 认证类，加入一些权限认证等方法
 * @author Administrator
 *
 */
class Auth{
    var $user = null;
    //专营店常量
    var $roleSellpoint = 1;
    //小区督导端常量
    var $roleSpsarea = 2;
    //专员端常量
    var $roleSpecial = 3;
    //大区总监常量
    var $roleRegion = 4;
    //区域总监常量
    var $roleArea  = 5;
    //总部常量
    var $roleHead = 6;
    //查看角色常量
    var $roleCheck = 7;
    //当前框架
    var $CI = null;
    //时间单位模型
    var $timeUnitModel = null;
    //补报权限模型
    var $supplementRoleModel = null;
    //补报审核模型
    var $supplementAuditModel = null;
    //导入额度模型
    var $importMoneyModel = null;
    //固定传播基金专营店关系模型
    var $spreadStoreModel = null;
    var $spreadProcessModel = null;
    var $spreadProcStoreModel = null;
    var $spreadProItemModel = null;
    var $configModel = null;
    /**
     * 构造函数
     * @param array $user
     */
    function Auth($user){
        $this->user = $user;
        //自定义类使用CI资源使用此方法
        $CI =& get_instance();
        $this->CI = $CI;
        //时段模型
        $CI->load->model('timeUnitModel');
        $this->timeUnitModel = $CI->timeUnitModel;
        //补报权限模型
        $CI->load->model('supplementRoleModel');
        $this->supplementRoleModel = $CI->supplementRoleModel;
        //补报审核模型
        $CI->load->model('supplementAuditModel');
        $this->supplementAuditModel = $CI->supplementAuditModel;
        //导入额度模型
        $CI->load->model('importMoneyModel');
        $this->importMoneyModel = $CI->importMoneyModel;
        
        $CI->load->model('spreadStoreModel');
        $this->spreadStoreModel = $CI->spreadStoreModel;
        $CI->load->model('spreadProcessModel');
        $this->spreadProcessModel = $CI->spreadProcessModel;
        $CI->load->model('spreadProcStoreModel');
        $this->spreadProcStoreModel = $CI->spreadProcStoreModel;
        $CI->load->model('spreadProItemModel');
        $this->spreadProItemModel = $CI->spreadProItemModel;
        
        $CI->load->model('configModel');
        $this->configModel = $CI->configModel;
    }
    /**
     * 是否有单店基金添加预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleBudgetAdd($procData, $isBubao = false){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }            
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['singleTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['singleTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有单店基金修改预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleBudgetEdit($procData, $isBubao = false){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }            
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['singleTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['singleTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看单店基金预算权限;
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleBudgetCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在单店基金预算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleBudgetAudit($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }            
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['singleTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['singleTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金结算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleSettleEdit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }            
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        //判断是否已经过结算申请时间，但是还未过结算审核时间，表示此时间段允许重新上传结算凭证
        if ($nowTime > $timeUnitData['singleTimeSetting']['settleApplyEnd'] && $nowTime <= $timeUnitData['singleTimeSetting']['settleAuditEnd']){
            return 3;
        }
        //判断是否已经过了结算申请时间
        if ($nowTime < $timeUnitData['singleTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['singleTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金结算查看权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleSettleCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 单店基金结算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleSettleAudit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }            
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['singleTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['singleTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 单店基金-修改金额权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleSettleChange($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部、地区才有金额修改权限
        if (!array_intersect(array('area','head'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['singleTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['singleTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有单店基金评分权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSingleSettleSubScore($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监、地区总监才有评分权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 1, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 1, 2)){
                return 2;
            }
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['singleTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['singleTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有权限申报天网行动
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isSingleNetAdd($procData, $isBubao = false){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        $findData = $this->importMoneyModel->getData(array(
            'storeId'   => $this->user['userId'],
            'timeUnit'  => $procData['timeUnit'],
            'year'      => $procData['year'],
            'type'      => 12,
        ));
        if($findData){
            return true;
        }else{
            return false;
        }
    }
    /**
     * 是否有城市提升申报权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCityBudgetAdd($procData, $isBubao = false){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('100CityApply'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 2, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 2, 2)){
                return 2;
            }            
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['cityTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['cityTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 城市提升预算修改权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCityBudgetEdit($procData, $isBubao = false){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //判断预算状态是否可以继续修改
        /*if (!in_array($procData['budgetAuditRs'], array(-1,0))){
            return false;
        }*/
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 2, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 2, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['cityTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['cityTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看城市提升预算权限;
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCityBudgetCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有城市提升预算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCityBudgetAudit($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 2, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 2, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['cityTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['cityTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有城市提升结算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCitySettleEdit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 2, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 2, 2)){
                return 2;
            }            
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        //判断是否已经过结算申请时间，但是还未过结算审核时间，表示此时间段允许重新上传结算凭证
        if ($nowTime > $timeUnitData['cityTimeSetting']['settleApplyEnd'] && $nowTime <= $timeUnitData['cityTimeSetting']['settleAuditEnd']){
            return 3;
        }
        //判断是否已经过了结算申请时间
        if ($nowTime < $timeUnitData['cityTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['cityTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
   /**
    * 城市提升结算查看权限
    * @param array $procData
    * @param boolean $isBubao 是否为补报
    * @return boolean
    */
    function isCitySettleCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 结算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCitySettleAudit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 2, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 2, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['cityTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['cityTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 城市提升-修改金额权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCitySettleChange($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部、地区才有金额修改权限
        if (!array_intersect(array('area','head'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['cityTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['cityTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有评分权限（城市提升暂无评分动作）
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCitySettleSubScore($procData, $isBubao = false){
        return false;
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监、地区总监才有评分权限
        if (!array_intersect(array('spsarea','region','area'), $this->user['userLimit'])){
            return false;
        }
        //是否为特殊补报
        if ($this->isCitySpecialBubao($procData)){
            return true;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['cityTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['cityTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金预算申报
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunBudgetAdd($procData = array(), $isBubao = false){
        return false;
    }
    /**
     * 巡展基金预算编辑
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunBudgetEdit($procData = array(), $isBubao = false){
        return false;
    }
    /**
     * 巡展基金预算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunBudgetCheck($procData = array(), $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金预算审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunBudgetAudit($procData = array(), $isBubao = false){
        return false;
    }
    /**
     * 巡展基金结算申请
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunSettleEdit($procData = array(), $isBubao = false){
        return false;
    }
    /**
     * 巡展基金结算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isXunSettleCheck($procData = array(), $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 巡展基金结算审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isXunSettleAudit($procData = array(), $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['xunTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['xunTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展预算申请
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarBudgetAdd($procData = array(), $isBubao = false){
        //return $this->isCityBudgetAdd($procData, $isBubao);
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 3, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 3, 2)){
                return 2;
            }
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展预算修改
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCarBudgetEdit($procData = array(), $isBubao = false){
        //return $this->isCityBudgetEdit($procData, $isBubao);
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 3, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 3, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展预算审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isCarBudgetAudit($procData = array(), $isBubao = false){
        //return $this->isCityBudgetAudit($procData, $isBubao);
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 3, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 3, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['carTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展预算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarBudgetCheck($procData = array(), $isBubao = false){
        //return $this->isCityBudgetCheck($procData, $isBubao);
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 车展结算申请
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarSettleEdit($procData = array(), $isBubao = false){
        //return $this->isCitySettleEdit($procData, $isBubao);
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 3, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 3, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        //判断是否已经过结算申请时间，但是还未过结算审核时间，表示此时间段允许重新上传结算凭证
        if ($nowTime > $timeUnitData['carTimeSetting']['settleApplyEnd'] && $nowTime <= $timeUnitData['carTimeSetting']['settleAuditEnd']){
            return 3;
        }
        //判断是否已经过了结算申请时间
        if ($nowTime < $timeUnitData['carTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展结算审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarSettleAudit($procData = array(), $isBubao = false){
        //return $this->isCitySettleAudit($procData, $isBubao);
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 3, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 3, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展结算金额修改
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarSettleChange($procData = array(), $isBubao = false){
        //return $this->isCitySettleChange($procData, $isBubao);
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部、地区才有金额修改权限
        if (!array_intersect(array('area','head'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['carTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['carTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 车展结算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isCarSettleCheck($procData = array(), $isBubao = false){
        //return $this->isCitySettleCheck($procData, $isBubao);
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金新增
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isSpreadBudgetAdd($procData = array(), $isBubao = false){
        if (!$procData['year']){
            return false;
        }
        //判断是否有申报权限
        $isBudgetAdd = $this->spreadStoreModel->isBudgetAdd($this->user['userId'], $procData['year']);
        if (!$isBudgetAdd){
            return false;
        }
        //固定传播基金年度费用只允许申报一次
        $findProcData = $this->spreadProcessModel->getData(array('storeId'=>$this->user['userId'],'year'=>$procData['year']));
        if ($findProcData){
            return false;
        }
        //补报
        if ($isBubao){
            
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 5, 2)){
                return 2;
            }
        }
        //判断是否满足时间条件
        $spreadApplyTime = $this->configModel->getConfigData('spreadApplyTime');
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $spreadApplyTime['startTime'] || $nowTime > $spreadApplyTime['endTime'] ){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金修改
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadBudgetEdit($procData = array(), $isBubao = false){
        if (!$procData['id']){
            return false;
        }
        //判断是否有申报权限
        $isBudgetAdd = $this->spreadStoreModel->isBudgetAdd($this->user['userId']);
        if (!$isBudgetAdd){
            return false;
        }
        //用户身份验证
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        if ($procData['id'] != $procData['belongProcId']){
            return false;
        }
        //审核状态验证
        if (in_array($procData['auditRs'], array(1,2))){
            return false;
        }
        //补报
        if ($isBubao){
        
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 5, 2)){
                return 2;
            }
        }
        //判断是否满足时间条件
        $spreadApplyTime = $this->configModel->getConfigData('spreadApplyTime');
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $spreadApplyTime['startTime'] || $nowTime > $spreadApplyTime['endTime'] ){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金删除
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadBudgetDel($procData = array(), $isBubao = false){
        if (!$procData['id']){
            return false;
        }
        //判断是否有申报权限
        $isBudgetAdd = $this->spreadStoreModel->isBudgetAdd($this->user['userId']);
        if (!$isBudgetAdd){
            return false;
        }
        //用户身份验证
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        if ($procData['id'] != $procData['belongProcId']){
            return false;
        }
        //审核状态验证
        if (in_array($procData['auditRs'], array(1,2))){
            return false;
        }
        //补报
        if ($isBubao){
        
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 5, 2)){
                return 2;
            }
        }
        //判断是否满足时间条件
        $spreadApplyTime = $this->configModel->getConfigData('spreadApplyTime');
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $spreadApplyTime['startTime'] || $nowTime > $spreadApplyTime['endTime'] ){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金项目审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     */
    function isSpreadBudgetAudit($procData = array(), $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有专员、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //上级已审核下级不能审核
        if ($this->user['userRole'] < $procData['auditRole']){
            return false;
        }
        //审核状态为待审核时才允许审核
        /* if ($procData['auditRs'] == 1) {
            return false;
        } */
        //查找是否已经提交双月检核凭证，如果已提交则不允许审核
        /* $findSubVoucher = $this->spreadProItemModel->getData(array('procId'=>$procData['id'],'auditRs >'=>-1,'voucher !='=>'a:0:{}'));
        if ($findSubVoucher){
            return false;
        } */
        //补报
        if ($isBubao){
        
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 5, 2)){
                return 2;
            }
        }
        //判断是否满足时间条件
        $spreadApplyTime = $this->configModel->getConfigData('spreadApplyTime');
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $spreadApplyTime['startTime'] || $nowTime > $spreadApplyTime['endTime'] ){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金预算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadBudgetCheck($procData = array(), $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        if ($this->user['userRole'] == $this->roleSellpoint){
            
            //判断是否是主单店或者是协办店列表中
            if ($procData['storeId'] != $this->user['userId']){
                $isInProcStore = $this->spreadProcStoreModel->isInProcStore($procData['id'], $this->user['userId']);
                if (!$isInProcStore){
                    return false;
                }
            }
        }
        
        return true;
    }
    /**
     * 固定传播基金结算发布
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadSettleEdit($procData = array(), $isBubao = false){
        if (!$procData['id']){
            return false;
        }
        //用户身份验证
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        if ($procData['id'] != $procData['belongProcId']){
            return false;
        }
        //审核状态验证
        if ($procData['auditRs'] != 1){
            return false;
        }
        
        return true;
    }
    /**
     * 固定传播基金结算审核
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadSettleAudit($procData = array(), $isBubao = false){
        if (!$procData['id']){
            return false;
        }
        //审核状态验证
        if ($procData['auditRs'] == -1){
            return false;
        }
        //只有专员、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //上级已审核下级不能审核
        if ($this->user['userRole'] < $procData['auditRole']){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['spreadTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['spreadTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 固定传播基金结算查看
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpreadSettleCheck($procData = array(), $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //审核状态验证
        if ($procData['auditRs'] == -1){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项单店基金添加预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialBudgetAdd($procData, $isBubao = false){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项单店基金修改预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialBudgetEdit($procData, $isBubao = false){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看专项单店基金预算权限;
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialBudgetCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在专项单店基金预算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialBudgetAudit($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['specialTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项单店基金结算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialSettleEdit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        //判断是否已经过结算申请时间，但是还未过结算审核时间，表示此时间段允许重新上传结算凭证
        if ($nowTime > $timeUnitData['specialTimeSetting']['settleApplyEnd'] && $nowTime <= $timeUnitData['specialTimeSetting']['settleAuditEnd']){
            return 3;
        }
        //判断是否已经过了结算申请时间
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项单店基金结算查看权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialSettleCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 专项单店基金结算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialSettleAudit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监才有审核权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项单店基金-修改金额权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialSettleChange($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部、地区才有金额修改权限
        if (!array_intersect(array('area','head'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有专项单店基金评分权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecialSettleSubScore($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有督导、大区总监、地区总监才有评分权限
        if (!array_intersect(array('spsarea','region'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 6, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 6, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specialTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['specialTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项城市基金添加预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecityBudgetAdd($procData, $isBubao = false){
        if ($procData['id']){
            return false;
        }
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specityTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specityTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有专项城市基金修改预算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecityBudgetEdit($procData, $isBubao = false){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit']) || !$procData['timeUnit']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        $nowTime = time();//当前时间戳在预算申请开始和结束时间之内
        if ($nowTime < $timeUnitData['specityTimeSetting']['budgetApplyStart'] || $nowTime > $timeUnitData['specityTimeSetting']['budgetApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否有查看专项城市基金预算权限;
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecityBudgetCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 判断用户是否存在专项城市基金预算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecityBudgetAudit($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有专员、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specityTimeSetting']['budgetAuditStart'] || $nowTime > $timeUnitData['specityTimeSetting']['budgetAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项城市基金结算申请权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecitySettleEdit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //用户身份验证
        if ($this->user['userRole'] != $this->roleSellpoint || !array_intersect(array('apply','100CityApply'), $this->user['userLimit'])){
            return false;
        }
        if($procData['storeId'] != $this->user['userId']){
            return false;
        }
        //数据有效性验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        //判断是否已经过结算申请时间，但是还未过结算审核时间，表示此时间段允许重新上传结算凭证
        if ($nowTime > $timeUnitData['specityTimeSetting']['settleApplyEnd'] && $nowTime <= $timeUnitData['specityTimeSetting']['settleAuditEnd']){
            return 3;
        }
        //判断是否已经过了结算申请时间
        if ($nowTime < $timeUnitData['specityTimeSetting']['settleApplyStart'] || $nowTime > $timeUnitData['specityTimeSetting']['settleApplyEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项城市基金结算查看权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecitySettleCheck($procData, $isBubao = false){
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        return true;
    }
    /**
     * 专项城市基金结算审核权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecitySettleAudit($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有专员、大区总监才有审核权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specityTimeSetting']['settleAuditStart'] || $nowTime > $timeUnitData['specityTimeSetting']['settleAuditEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 专项城市基金-修改金额权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecitySettleChange($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有总部、地区才有金额修改权限
        if (!array_intersect(array('area','head'), $this->user['userLimit'])){
            return false;
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specityTimeSetting']['settleChangeStart'] || $nowTime > $timeUnitData['specityTimeSetting']['settleChangeEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有专项城市基金评分权限
     * @param array $procData
     * @param boolean $isBubao 是否为补报
     * @return boolean
     */
    function isSpecitySettleSubScore($procData, $isBubao = false){
        //时间验证
        if (!isset($procData['id']) || !$procData['id']){
            return false;
        }
        //只有专员、大区总监、地区总监才有评分权限
        if (!array_intersect(array('special','region'), $this->user['userLimit'])){
            return false;
        }
        //上级审核过，下级不允许审核
        if ($this->user['userRole'] < $procData['scoreRole']) {
            return false;
        }
        //地区端取消评分时间限制
        if(array_intersect(array('area'), $this->user['userLimit'])){
            return true;
        }
        //补报
        if ($isBubao){
            if ($this->isBubao($procData, 7, 1)){
                return true;
            }else{
                return false;
            }
        }else{
            //是否为特殊补报
            if ($this->isBubao($procData, 7, 2)){
                return 2;
            }
        }
        //时间段缓存数据
        $timeUnitDataList = $this->timeUnitModel->getCacheData('timeUnitDataList');
        if (!isset($timeUnitDataList[$procData['year']][$procData['timeUnit']])){
            return false;
        }else{
            $timeUnitData = $timeUnitDataList[$procData['year']][$procData['timeUnit']];
        }
        //当前时间
        $nowTime = time();
        if ($nowTime < $timeUnitData['specityTimeSetting']['settleScoreStart'] || $nowTime > $timeUnitData['specityTimeSetting']['settleScoreEnd'] ){
            return false;
        }
        return true;
    }
    /**
     * 是否具有补报权限
     * @param array $procData
     * @param array $fundType 基金类型
     * 1 => '单店基金',
     * 2 => '城市提升基金',
     * 3 => '车展基金',
     * 4 => '巡展基金',
     * 5 => '固定传播基金',
     * 6 => '专项基金'
     * @param number $type 补报类型（1:普通补报，2：特殊补报）
     * @return boolean
     */
    function isBubao($procData,$fundType,$type=1){
        //年份验证
        if (!isset($procData['year']) || !$procData['year']){
            return false;
        }
        //时间验证
        if (!isset($procData['timeUnit'])){
            return false;
        }
        //查询符合条件的专营店ID集，减少数据库查询次数
        $storeIdsByTimeUnit = $this->supplementRoleModel->getValidStoreIdsByTimeUnit($fundType, $type,$procData['year']);
        if (isset($storeIdsByTimeUnit[$procData['timeUnit']]) && in_array($procData['storeId'], $storeIdsByTimeUnit[$procData['timeUnit']])) {
            return true;
        }else{
            return false;
        }
    }
    /**
     * 判断是否有补报开通权限
     */
    function isSupplementEdit(){
        //地区端、总部端可以开通普通补报权限
        if (!array_intersect(array('head','area'), $this->user['userLimit'])){
            return false;
        }
        return true;
    }
    /**
     * 是否具有开通审核权限
     * @return boolean
     */
    function isAuditLimitEdit(){
        //总部端可以开通审核权限
        if (!array_intersect(array('head','area'), $this->user['userLimit'])){
            return false;
        }
        return true;
    }
    /**
     * 判断是否有导入管理权限
     * @return boolean
     */
    function isImport(){
        if ($this->user['userRole'] != $this->roleHead){
            return false;
        }
        return true;
    }
}